<template>
	<view class="content">
		<image class="logo" src="/static/logo.png" @click="reflushPage()"></image>
		<view class="text-area">
			<button class="backpage" @click="backPage">返回上一页</button>
			<button class="backpage" @click="toDemo2">到下一页</button>
			<button class="backpage" @click="lastPageFun">执行上一页函数</button>
			<button class="title">我是query传递的参数{{query}}</button>
			<button class="title">我是params传递的参数{{params}}</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				query: '',
				params: ''
			}
		},
		onLoad() {
			console.log(uni.$router.query);
			console.log(uni.$router.params);
		},
		methods: {
			publicExecMethod(...arg) {
				console.log(arg);
				console.log('执行execMethod');
			},
			toDemo2() {
				uni.$router.push('pages/demo2/demo2')
			},
			reflushPage() {
				uni.$router.reloadPage()
			},
			lastPageFun() {
				console.log(uni.$router.params);
				// 推荐用该方法触发上一页event方法
				uni.$router.trigger('我会传到上一页') // 第一个任意值，会传到上页，第二个不传只触发上页,传数组路径可执行多个页 触发上一页event事件方法
			},
			backPage() {
				uni.$router.back({
					url: 'pages/index/index',
					params: {
						test: '返回上一页携带的值'
					}
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		flex-direction: column;
		justify-content: center;
		padding: 10px 10px;

	}

	.title {
		margin: 20px 0;
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>